#include "StdAfx.h"
#include "FunctionDriverArc.h"
#include "LabelTools.h"
#include "RegFunctionDriverHelper.h"
#include "../ArcBuilder.h"
CFunctionDriverArc::CFunctionDriverArc()
{
}
CFunctionDriverArc::~CFunctionDriverArc()
{
}

const Standard_GUID& CFunctionDriverArc::GetID() {
	static Standard_GUID anID(ARC_CRPE_GUID);
	return anID;
}


void CFunctionDriverArc::Validate(TFunction_Logbook& log) const
{
	// We validate the object label ( Label() ), all the arguments and the results of the object:
	log.SetValid(Label(), Standard_True);
}

Standard_Boolean CFunctionDriverArc::MustExecute(const TFunction_Logbook& log) const
{

	if (log.IsModified(Label())) return Standard_True; 

	if(CArcInfo::IsModified(Label(), log))
		return Standard_True;

	return Standard_False;
}

Standard_Integer CFunctionDriverArc::Execute(TFunction_Logbook& log) const
{
	CArcInfo info;
	if(!info.GetFromLabel(Label()))
		return 1;

	TopoDS_Shape shape;
	CArcBuilder builder;

	if(!builder.Build(&info, shape))
		return 1;

	// Build a TNaming_NamedShape using built box
	TNaming_Builder B(Label());
	B.Generated(shape);

	return 0;
}


//////////////////////////////////////////////////////////////////////////
IMPLEMENT_FUNCTIONDRIVER_HANDLE(CFunctionDriverArc)

REGISTER_FUNCTIONDRIVER(CFunctionDriverArc)